﻿<UserControl x:Class="FSquirrel.Views.CopierView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ignore="http://www.ignore.com" xmlns:helper="clr-namespace:FSquirrel.Helpers"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
             mc:Ignorable="d ignore"
        DataContext="{Binding CopierVM, Source={StaticResource Locator}}">

    <UserControl.Resources>
        <helper:FileSizeConverter x:Key="FileSizeConverter" />
    </UserControl.Resources>

    <Grid Opacity="1" Background="{x:Null}">
        <Rectangle x:Name="MainRectangle" Margin="0,0,0,0" Style="{DynamicResource UserControlOverlayRectangleStyle}"/>
        <Grid Width="500" Height="480" Background="{x:Static SystemColors.WindowBrush}">
            <Grid.RowDefinitions>
                <RowDefinition Height="189*" />
                <RowDefinition Height="280*" />
                <RowDefinition Height="25*" />
            </Grid.RowDefinitions>
            <GroupBox Header="Copy Details:" Margin="0,0,5,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="1">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="28"/>
                        <RowDefinition Height="2*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="80*" />
                        <ColumnDefinition Width="162*" />
                        <ColumnDefinition Width="127*" />
                    </Grid.ColumnDefinitions>
                    <Label Content="Filename:" Grid.Row="0" Grid.Column="0" FontWeight="Bold" />
                    <Label Grid.Row="0" Grid.Column="1" Height="28" Content="{Binding Path=CurrentFile}"  />
                    <Label Content="File:" Grid.Row="1" Grid.Column="0" Height="28" FontWeight="Bold" />
                    <Label Content="Completed:" Grid.Row="2" Grid.Column="0" Height="28" FontWeight="Bold" />
                    <Label Content="Disk Space:" Grid.Row="3" Grid.Column="0" Height="28" FontWeight="Bold" />
                    <Label Content="Destination:" Grid.Row="4" Grid.Column="0" Height="28" FontWeight="Bold" />
                    <ProgressBar Grid.Column="1" Grid.Row="1" x:Name="filesprogres" Value="{Binding Path=CurrentFilePercentage}"/>
                    <ProgressBar Grid.Column="1" Grid.Row="2" x:Name="totalprogres" Maximum="{Binding Path=CopyListCapacity}" Value="{Binding Path=CopyListCount}" />
                    <ProgressBar Grid.Column="1" Grid.Row="3" x:Name="diskspaceleft" Maximum="{Binding Path=TotalDiskSpace}" Value="{Binding Path=DiskSpaceOnDrive}" />
                    <TextBlock Text="{Binding Path=CurrentFilePercentage, StringFormat=' {0:N0} %'}" Grid.Row="1" Grid.Column="2" Height="28" />
                    <TextBlock  Grid.Row="2" Grid.Column="2" Height="28" >
                        <TextBlock.Text>
                            <MultiBinding StringFormat=" {0} of {1}">
                                <Binding Path="CopyListCount"></Binding>
                                <Binding Path="CopyListCapacity"></Binding>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                    <TextBlock Grid.Row="3" Grid.Column="2" Height="28" Text="{Binding Path=SpaceFree, Converter={StaticResource FileSizeConverter}, StringFormat='Free : {0}'}" Margin="5,0,0,0" />
                    <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=CopyPath}" BorderBrush="Black" Margin="2,5,18,0" ></TextBox>
                    <Button Content="..."  Grid.Column="1" Grid.Row="4" Margin="5,5,2,2" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=BrowseCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <ComboBox  Grid.Row="4" Grid.Column="2" Margin="5,2" ItemsSource="{Binding Path=RemovableDriveList}" IsEnabled="{Binding HasItems, RelativeSource={RelativeSource Self}}" Name="RemovableCombo">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cmd:EventToCommand Command="{Binding Path=RemovableSelectionCommand}" CommandParameter="{Binding ElementName=RemovableCombo,Path=SelectedItem}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ComboBox>
                    <Button Grid.Row="5" Grid.Column="2" Content="Go!" IsEnabled="{Binding Path=IsNotCopying}" Margin="2,1">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=GoCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button Content="Hide" Grid.Column="2" Grid.RowSpan="1" Height="23" HorizontalAlignment="Right" Margin="5,2" VerticalAlignment="Top">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=VisibilityCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </GroupBox>
            <DataGrid Grid.Row="1" ItemsSource="{Binding Path=RequestList}" AutoGenerateColumns="False" Grid.RowSpan="1">
                <DataGrid.AlternatingRowBackground>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#33667FF8" Offset="0.006" />
                        <GradientStop Color="White" Offset="0.983" />
                    </LinearGradientBrush>
                </DataGrid.AlternatingRowBackground>
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" CanUserReorder="False" />
                    <DataGridTextColumn Binding="{Binding Path=Category}" Header="Category" CanUserReorder="False" />
                    <DataGridTextColumn Binding="{Binding Path=Size, Converter={StaticResource FileSizeConverter}}" Header="Size" CanUserReorder="False"  />

                </DataGrid.Columns>
            </DataGrid>
            <StatusBar Grid.Row="2">
                <StatusBarItem HorizontalAlignment="Right">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=RequestList.Count, StringFormat='Item Count : {0}'}" Margin="0,0,5,0"/>
                        <Separator/>
                        <TextBlock Text="{Binding Path=TotalSize, Converter={StaticResource FileSizeConverter}, StringFormat='Total Size : {0}'}"  Margin="0,0,5,0"/>
                    </StackPanel>
                </StatusBarItem>
            </StatusBar>
        </Grid>
    </Grid>
</UserControl>